<?php
namespace App\Http\Controllers;

use App\Models\Area;
use Illuminate\Support\Facades\Response;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
/**
 *
 * @author Joker
 *        
 */
class AreaController extends Controller
{
    
    /**
     * 根据父分类获取子分类 职位
     */
    public function getChildAreas(Request $req)
    {
        $pid = $req->only('pid');
        if($pid)
        {
            $result = Area::where('pid','=',$pid)->get();
            if(empty($result))
            {
                return Response::json(array('status'=>'flase','msg'=>'没有更多分类','data'=>''));
            }
            else
            {
                return Response::json(array('status'=>'success','msg'=>'获取分类成功','data'=>$result));
            }
        }
        return Response::json(array('status'=>'false','msg'=>'没有更多分类','data'=>''));
    }
    
    public function checkLogin()
    {
        $user = Auth::user();
        
        if(isset($user)) {
            return toJson('success','成功');
        } else {
            return toJson('error','请先登录');
        }
    }
}
